<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="ajax" uri="javawebparts/ajaxparts/taglib"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<head>
	<sx:head extraLocales="en-us,nl-nl,de-de" />
	<script>
	function required(views){
		if(views.value == '' || views.value == null){
			views.focus();
			return false;
		}
	}
 	function disp1(name) {
 		//alert(document.getElementById("tempImg").height);
 		var image = new Image();
 		image.src = document.getElementsByName('upload').value;
 		// alert("height  :"+image.height);
 		// alert("width  :"+image.width);
 	  	if (document.images){
 	  		var i, img;
			for (i = 0; i < document.images.length; i++) {
			// alert(document.images[i].src)
				// alert(document.images[i].imageName + " -- > " + i + " id --> " + document.images[i].name)
    			if (document.images[i].name == name) {
    				// alert('hi');
    				// alert(document.images[i]);
					// alert(document.images[i].name);
					// alert(document.images[i].id);
					// alert(document.images[i].height);
					// alert(document.images[i].width);
					// document.getElementById('imgWidth').value = document.images[i].width;
  					// document.getElementById('imgHeight').value = document.images[i].height;
				}
			}
		}
    }
	</script>
</head>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<s:form action="createCampaign.htm" method="post" theme="simple" enctype="multipart/form-data">
	<s:hidden name="id" value="%{bannerCampaigns.id}" />
	<s:hidden name="bannerCampaigns.id" value="%{bannerCampaigns.id}" />
	<table width="100%" cellpadding="0" cellspacing="0">
		<tr>
			<td>
			<div class="blue-text16" style="margin: 0px 0px 0px 0px">
				<s:text name="addNewCampaign.header"></s:text>
			</div>
			<div class="header-separator-bg" style="margin: 10px 5px 17px 0px"></div>
			<div style="margin: 0px 0px 12px 0px">
				<table border="0" cellspacing="2" cellpadding="2">
					<tr>
						<td colspan="2">
							<s:actionerror cssClass="error-text"/>
							<s:actionmessage cssClass="error-text"/>
							<s:fielderror cssClass="error-text"/>
						</td>
					</tr>
					<tr>
						<td align="right" nowrap class="common-bold-text">
							<s:text name="addNewCampaign.campaignname" />
						</td>
						<td nowrap="nowrap">
							<s:textfield theme="simple" cssClass="textfield"
								name="bannerCampaigns.campaign"
								value="%{bannerCampaigns.campaign}" size="20" />
						</td>
					</tr>
					<tr>
						<td align="right" nowrap class="common-bold-text">
							<s:text name="addNewCampaign.uploadbannerimage"></s:text>
						</td>
						<td nowrap>
							<div class="fileinputs">
			                    	<s:file name="upload" theme="simple" id="tempImg" cssClass="file" onchange="javascript:disp1('upload');document.getElementById('Input').value = this.value" />
			                      		<div class="fakefile">
					                        <table border="0" cellpadding="2" cellspacing="0">
					                          <tr>
			                           			 <td>
			                           			 <input name="Input" class="textfield" id="Input"  readonly="readonly"/></td>
			                            		 <td>
			                            			<table width="100%" border="0" cellspacing="0" cellpadding="0">
													  <tr>
													    <td class="btn-grey-left1"></td>
													    <td valign="top" class="btn-grey-middle1">
														   <div style="margin:1px 0px 0px 0px">
														   	<input name="button" type="button" class="submit-btn-common1" value="<s:text name="button.upload" />" />
														   </div>
													    </td>
													    <td valign="top" class="btn-grey-right1"></td>
													  </tr>
													</table>
												</td>
					                          </tr>
					                        </table>
										</div>
									</div>
						</td>
					</tr>
					<s:if test="%{bannerCampaigns.image != null}">
						<tr>
							<td align="right" nowrap class="common-bold-text"><blockquote><blockquote>
								<s:text name="addNewCampaign.uploadedbannerimage" />
							</blockquote></blockquote></td>
							<td>
								<div>
									<img name="bannerCampaigns.image" src="servlet/ImageServlet?dto=BannerCampaigns&id=<s:property value="bannerCampaigns.id"/>"
										alt="alttext" width="200" height="60" border="0"
											style="margin: 5px 0px 0px 5px">
								</div>
							</td>
						</tr>
					</s:if>
					<tr>
						<td align="right" class="common-bold-text">
							<s:text name="addNewCampaign.size" />
						</td>
						<td class="common-bold-text">
							<s:text name="addNewCampaign.width" />
							<s:textfield theme="simple" cssClass="textfield" id="imgWidth"
								name="bannerCampaigns.width" value="%{bannerCampaigns.width}" size="10"/>
							&nbsp;&nbsp;&nbsp;&nbsp; <s:text name="addNewCampaign.height" />
							<s:textfield theme="simple" cssClass="textfield" id="imgHeight"
								name="bannerCampaigns.height" value="%{bannerCampaigns.height}" size="10"/>
						</td>
					</tr>
					<tr>
						<td align="right" valign="top" nowrap class="common-bold-text">
							<s:text name="addNewCampaign.campaigntype"></s:text>
						</td>

						<td nowrap>

							<table border="0" cellspacing="0" cellpadding="9">
								<tr>
									<td nowrap="nowrap" class="common-text">
										<s:radio theme="simple" list="#{'1':'Per click'}" name="campaignType"
											cssClass="textfield" onclick="javascript:disableTextBoxesOnClicks(document.getElementById('views'),document.getElementById('days'),document.getElementById('clicks'))"/>
									</td>
									<td class="common-bold-text">
										<s:textfield theme="simple" cssClass="textfield"
											name="bannerCampaigns.maxClicks" id="clicks" disabled="true"
											value="%{bannerCampaigns.maxClicks}" size="20" />
										<s:text name="addNewCampaign.insertnumberofclicks"></s:text>
									</td>
								</tr>
								<tr>
									<td nowrap="nowrap"  class="common-text">
										<s:radio theme="simple" list="#{'2':'Per view'}" name="campaignType"
											cssClass="textfield" onclick="javaScript:disableTextBoxesOnViews(document.getElementById('views'),document.getElementById('days'),document.getElementById('clicks'))" />
									</td>
									<td class="common-bold-text">
										<s:textfield theme="simple" cssClass="textfield" onblur="javascript: return required(document.getElementById('views'));"
											name="bannerCampaigns.maxViews" id="views" disabled="true"
											value="%{bannerCampaigns.maxViews}" size="20" />
										<s:text name="addNewCampaign.insertnumberofviews" />
									</td>
								</tr>
							<!-- <tr>
									<td nowrap>
										<s:radio theme="simple" cssClass="textfield"
											list="#{'1':'number of impressions'}"
											value="%{bannerCampaigns.type}" name="bannerCampaigns.type" />
									</td>
									<td class="common-bold-text">
										<s:textfield theme="simple" cssClass="textfield"
											name="bannerCampaigns.maxImpressions"
											value="%{bannerCampaigns.maxImpressions}" size="20" />
										impressions allowed
									</td>
								</tr> -->
								<tr>
									<td valign="top" nowrap="nowrap"  class="common-text">
										<s:radio theme="simple" onclick="javaScript:disableTextBoxesOnDays(document.getElementById('views'),document.getElementById('days'),document.getElementById('clicks'))"
											 name="campaignType" list="#{'3':'Per days'}" cssClass="textfield" />
									</td>
									<td class="common-bold-text">
										<s:textfield theme="simple" cssClass="textfield"
											name="bannerCampaigns.maxDays" id="days" disabled="true"
											value="%{bannerCampaigns.maxDays}" size="20" />
										<s:text name="addNewCampaign.insertnumberofdays" />
									</td>
								</tr>
							</table>
						</td>

					</tr>
					<tr>
						<td class="common-bold-text" width="15%" align="right" valign="top">
							<b><s:text name="addNewCampaign.bannertype" /> </b></td>
						<td valign="top" class="error-text">
							<s:select list="bannerSettingsList" id="bannerType" listKey="id" listValue="formatName" onchange="this.options[this.selectedIndex].value;" name="bannerTypeId" cssClass="Textfield" />
						</td>
					</tr>
					<!--<tr>
						<td class="common-bold-text" width="15%" align="right" valign="top"> Type info:</td>
						<td valign="top" class="error-text"><div id="info"><i>
						<s:if test="%{banner_campaigns.clicks != null}">
							<s:text name="add_new_campaign.click"></s:text>
						</s:if>
						<s:elseif test="%{banner_campaigns.views != null}">
							<s:text name="add_new_campaign.view" />
						</s:elseif>
						<s:elseif test="%{banner_campaigns.days != null}">
							<s:text name="add_new_campaign.day"></s:text>
						</s:elseif>
						<s:else>
							<s:text name="add_new_campaign.select_banner_type" />
						</s:else>
						</i></div></td>
					</tr>-->
					<tr>
						<td class="common-bold-text" width="15%" align="right" valign="top">
							<b><s:text name="addNewCampaign.startdate" /> </b></td>
						<td valign="top" nowrap="nowrap" class="common-text" >
							<s:text name="addNewCampaign.format_MM_dd_yyyy" />
							<sx:datetimepicker type="date" cssClass="Textfiled-border" displayFormat="MM/dd/yyyy"
								toggleType="wipe" toggleDuration="200" name="bannerCampaigns.startDate" />
						</td>
					</tr>
					<tr>
						<td class="common-bold-text" width="15%" align="right" valign="top">
							<b><s:text name="addNewCampaign.category" /> </b></td>
						<td valign="top" class="common-text">
							<div id="selectedCatId">
							<s:if test="%{bannerCampaigns.categories != null}">
								<s:hidden name="categoryId" value="%{bannerCampaigns.generalCategories.categoryId}"></s:hidden>
								<s:iterator value="bannerCampaigns.categories" var="categories"
									status="status">
									<s:property value="%{bannerCampaigns.categories[#status.index]}" />
									<s:if test="#status.last == false">-></s:if>
								</s:iterator>
							</s:if>
							<s:else>
								<s:text name="addSellAuctionItem.category.msg" />
							</s:else>
						</div>
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
                    	<td>
                    		<table border="0" cellspacing="0" cellpadding="0">
			                  	<tr>
			                    	<td><img src="images/middle/btn-grey-left1.gif" alt=" " width="6" height="23" /></td>
			                      	<td class="btn-grey-middle1 "><input type="button" onclick="PPPCC=window.open('<%= basePath + "ajax/showCategoryTreeAction.htm" %>','CurrencyConverter','width=600,height=400,scrollbars=yes,resizable=false');PPPCC.focus()" name="Select Category" value="Select Category" class="submit-btn-common" /></td>
			                      <td><img src="images/middle/btn-grey-right1.gif" alt=" " width="6" height="23" /></td>
			                    </tr>
		                  </table>
                    	</td>
                    </tr>
				<!-- <tr>

						<td align="right" class="common-bold-text">
							target:
						</td>
						<td>
							<s:select theme="simple" name="bannerCampaigns.targetTag"
								value="%{bannerCampaigns.targetTag}" cssClass="textfield"
								list="#{'':'page default', '_self':'same frame', '_top':'whole page', '_blank':'new window', '_parent':'parent frame', 'new':'reuse new window'}" />
						</td>
					</tr> -->

					<tr>
						<td align="right" class="common-bold-text">
							<s:text name="addNewCampaign.redirecturl" />
						</td>
						<td>
							<s:textfield theme="simple" cssClass="textfield"
								name="bannerCampaigns.redirectUrl"
								value="%{bannerCampaigns.redirectUrl}" size="60" />
						</td>
					</tr>
					<tr>
						<td align="right" class="common-bold-text">
							<s:text name="addNewCampaign.undertext"></s:text>
						</td>
						<td>
							<s:textfield theme="simple" cssClass="textfield"
								name="bannerCampaigns.underText"
								value="%{bannerCampaigns.underText}" size="60" />
						</td>
					</tr>

					<tr>
						<td align="right" class="common-bold-text">
							<s:text name="addNewCampaign.alttext"></s:text>
						</td>
						<td>
							<s:textfield theme="simple" cssClass="textfield"
								name="bannerCampaigns.altText"
								value="%{bannerCampaigns.altText}" size="60" />
						</td>
					</tr>
				<!-- 	<tr>
						<td align="right" class="common-bold-text">
							banner url:
						</td>
						<td>
							<s:textfield theme="simple" cssClass="textfield"
								name="bannerCampaigns.bannerUrl"
								value="%{bannerCampaigns.bannerUrl}" size="60" />


						</td>
					</tr> -->
					<tr>
						<td align="right" valign="top" nowrap class="common-bold-text">
							<s:text name="addNewCampaign.note" />
						</td>
						<td class="verdana12darkgreybold">
							<s:textarea theme="simple" rows="7" cssClass="textfield"
								name="bannerCampaigns.textBanner" cols="50"
								value="%{bannerCampaigns.textBanner}" />
							<br>
						</td>
					</tr>
					<tr><td colspan="2">&nbsp;</td></tr>
					<tr>
						<td align="right" class="common-text">

						</td>
						<td align="left" class="common-text">
							<table border="0" cellspacing="0" cellpadding="0">
								<tr>
									<td class="btn-grey-left1"></td>
									<td class="btn-grey-middle1 ">
										<input type="submit" value="Submit" class="submit-btn-common" >
									</td>
									<td class="btn-grey-right1"></td>
									<td class="btn-grey-left1"></td>
									<td class="btn-grey-middle1 ">
										<input type="button" value="Reset" class="submit-btn-common">
									</td>
									<td class="btn-grey-right1"></td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</div>
			</td>
		</tr>
	</table>
</s:form>